<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../cssmui/mui.min.css" rel="stylesheet" />
		<link href="../../cssmui/mui.picker.min.css" rel="stylesheet" />
		<!--App自定义的css-->
		<link href="../../css/hyl.css" rel="stylesheet" />
		<!--引用 js-->
		<script src="../../hyl/mui/mui.js"></script>

		<script src="../../hyl/mui/mui.picker.all.js"></script>
		<!-- 	<script src="../../mui/common.js"></script> -->
		<script src="../../js/vue.min2.6.10.js"></script>
		<script src="../../dbm/designsql.js"></script>
		<script src="../../hyl/util/core.js"></script>
		<script src="../../hyl/plus/file.js"></script>
		<script src="../../hyl/plus/sqlite.web.js"></script>
		<script src="../../hyl/plus/storage.js"></script>
		<script src="../../hyl/md/sql-modeldata.js"></script>

		<script src="../../hyl/str/py.js"></script>
		<script src="../../hyl/mui/img.js"></script>
		<script src="../../hyl/mui/loading.js"></script>
		<script src="../../hyl/mui/data.city.3.js"></script>
		<script src="../../hyl/mui/vue-mui-ext.js"></script>
		<script src="../../hyl/mui/vue-mui-img.js"></script>
		<script src="../dao/good_dao.js"></script>
		<script src="../dao/my_conf_dao.js"></script>
		<style type="text/css">
			.input70 {
				width: 70%;
			}

			.mybtn {
				margin-left: 5px;
				margin-right: 0px;
			}

			.mui-content {
				margin-top: 3px;
				margin-bottom: 70px;
			}

			.table-view-cell {
				height: 40px;
			}

			.li_item_label {
				padding: 10px 15px;
			}

			.table-view-cell:after {
				position: absolute;
				right: 5px;
				bottom: 0;
				left: 5px;
				height: 1px;
				content: '';
				-webkit-transform: scaleY(.5);
				transform: scaleY(.5);
				background-color: #c8c7cc;
			}
		</style>
	</head>
	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">产品信息</h1>
			<button id="scanBtn" onclick="clicked('../../plus/barcode_scan.html',true,true)" class="mui-pull-right myheadBtn"
			 type="button" onclick="return false; ">扫描</button>

		</header>
		<div class="mui-content" id="el" v-cloak>
			<form class="mui-input-group">
				<mui-slider-imgs ref="slider1" @click="onSelect" :imagelist="formdata.imgs"></mui-slider-imgs>
				<mui-up-imgs upurl="http://www.srv.com/upload?c=1234&s=tata" v-model="formdata.tx2"></mui-up-imgs>
				<ul class="mui-table-view">
					<li class=" ">
						<div class=" mui-input-row li_item">
							<label class="mui-table-cell mui-col-sm-3 mui-col-xs-3 li_item_label">识别码</label>
							<div class="mui-table-cell mui-col-sm-9 mui-col-xs-9">
								<input v-model="formdata.t2" type="text" class="mui-input-clear " placeholder="必填，扫码或手输">
							</div>
						</div>
						<div class=" mui-input-row li_item">
							<label class="mui-table-cell mui-col-sm-3 mui-col-xs-3 li_item_label ">分类</label>
							<div class="mui-table-cell mui-col-sm-9 mui-col-xs-9">
								<mui-select ref="gclass1" save="v" :layer="1" :options="dict.gclass" v-model="formdata.i1"></mui-select>
							</div>
						</div>
						<div class=" mui-input-row li_item">
							<label class="mui-table-cell mui-col-sm-3 mui-col-xs-3 li_item_label">名称</label>
							<div class="mui-table-cell mui-col-sm-9 mui-col-xs-9">
								<input v-model="formdata.t1" type="text" class="mui-input-clear " placeholder="必填">
							</div>
						</div>
						<div class=" mui-input-row li_item">
							<label class="mui-table-cell mui-col-sm-3 mui-col-xs-3 li_item_label">拼音</label>
							<div class="mui-table-cell mui-col-sm-9 mui-col-xs-9">
								<input v-model="formdata.t3" type="text" readonly>
							</div>
						</div>
						<div class=" mui-input-row li_item">
							<label class="mui-table-cell mui-col-sm-3 mui-col-xs-3 li_item_label">包装</label>
							<div class="mui-table-cell mui-col-sm-9 mui-col-xs-9">
								<input v-model="formdata.t6" type="text" class="mui-input-clear " placeholder="">
							</div>
						</div>

						<div class=" mui-input-row li_item">
							<label class="mui-table-cell mui-col-sm-3 mui-col-xs-3 li_item_label">单重|kg</label>
							<div class="mui-table-cell mui-col-sm-9 mui-col-xs-9">
								<input v-model="formdata.i3" type="number" class="inputnum mui-input-clear" placeholder="请输入有效数值">
							</div>
						</div>

						<div class=" mui-input-row li_item">
							<label class="mui-table-cell mui-col-sm-3 mui-col-xs-3 li_item_label">产地</label>
							<div class="mui-table-cell mui-col-sm-9 mui-col-xs-9">
								<input v-model="formdata.t4" type="text" class="mui-input-clear " placeholder="">
							</div>
						</div>
						<div class="mui-input-row li_item">
							<label class="mui-table-cell mui-col-sm-3 mui-col-xs-3 li_item_label">体积</label>
							<div class="mui-table-cell mui-col-sm-9 mui-col-xs-9">
								<input v-model="formdata.i2" type="number" class="mui-input-clear inputnum" placeholder="请输入有效数值">
							</div>
						</div>

						<div class="mui-input-row li_item">
							<label class="mui-table-cell mui-col-sm-3 mui-col-xs-3 li_item_label">质保期|天</label>
							<div class="mui-table-cell mui-col-sm-9 mui-col-xs-9">
								<input v-model="formdata.i6" type="number" class="mui-input-clear inputnum" placeholder="请输入有效数值">
							</div>
						</div>

						<div class="mui-input-row li_item">
							<label class="mui-table-cell mui-col-sm-3 mui-col-xs-3 li_item_label">状态</label>
							<div class="mui-table-cell mui-col-sm-9 mui-col-xs-9">
								<!-- ref="switch"   -->
								<mui-switch v-model="formdata.is1"></mui-switch>
							</div>
						</div>
					</li>
					<li class="mui-table-view-cell mui-collapse ">
						<a class="mui-navigate-right " href="# ">使用说明</a>
						<div class="mui-collapse-content " style="padding: 0px;">
							<textarea v-model="formdata.tx1" rows="16" class="ptext" style="margin:0px" placeholder=""></textarea>
						</div>
					</li>
				</ul>
				<div class="mui-card">
					<div class="mui-card-header mui-btn-blue">价格设置</div>
					<div class="mui-card-content">
						<div class="mui-row ">
							<label class="table-view-cell mui-col-sm-7 mui-col-xs-7 li_item_label">进价</label>
							<div class="table-view-cell mui-col-sm-5 mui-col-xs-5">
								<input v-model="formdata.i4" type="number" class="inputnum" placeholder="请输入有效数值">
							</div>
						</div>
						<div class=" mui-row">
							<label class=" table-view-cell mui-col-sm-7 mui-col-xs-7 li_item_label">售价</label>
							<div class="  table-view-cell mui-col-sm-5 mui-col-xs-5 ">
								<input v-model="formdata.i5" type="number" class="inputnum" placeholder="请输入有效数值">
							</div>
						</div>
						<!-- 	<div id="divprices">
							<div class="mui-row " v-for="item in lvprices">
								<label class="table-view-cell mui-col-sm-7 mui-col-xs-7 li_item_label">{{item.name}}</label>
								<div class="table-view-cell mui-col-sm-5 mui-col-xs-5">
									<input v-model="item.price" v-number-only type="number" class="inputnum" placeholder="请输入有效数值">
								</div>
							</div>
						</div> -->
					</div>

				</div>
				<br>
				<input type="hidden" id="gimg" />
			</form>

		</div>
		<nav class="mui-bar mui-bar-tab">
			<a class="mui-tab-item" href="create">
				<span class="mui-tab-label">添加</span>
			</a>
			<a class="mui-tab-item" href="save">
				<span class="mui-tab-label">保存</span>
			</a>
		</nav>

	</body>

</html>


<script src="../../hyl/page-muiIni.js"></script>
<script type="text/javascript">
	var _tb_contacts = null;
	var Sto_key = 'ing_goods';
	var _request = app._request || 0;
	var _subpageurls = ['class_info.html'];
	var goodDao, confDao;
	var vm;
	goodDao = new good_dao(_mydb_);
	confDao = new my_conf_dao(_mydb_);
	//console.log('_Dict.cgroup',_Dict.cgroup)
	//--------------创建vue实例,暂不绑定到对象------------------
	var vuedata = {
		//	el: '#el',
		data: {
			timer: null,
			formdata: null,			
			dict: {
				gclass: null
			}
		},
		//定义内部方法
		methods: {
			/**渲染以后才能调用
			 * @param {Object} res
			 */
			iniDict(res) {
				var that = this;
				if (res.indexOf("gclass") > -1) {
					confDao.getDict('gclass', function(rc) {
						//读取数据,初始化组件
					
						this.dict.gclass=rc;
					});
				}
			},
			onTask() {
				//console.log(Sto_key,this.formdata)
				_STO.setItem(Sto_key, this.formdata);//缓存输入的数据
			},
			onSave() {
				//if (!_IS.checkNumber(this.formdata.uname)) return;
				var ta = this;
				//console.log('onSave',this.formdata,userDao)
				userDao.MD.setObjById(this.formdata, function(s) {
					app._result.code = 1;
					//app._result.data = this.formdata;
					app.blur();
					ta.$forceUpdate();
					_STO.removeItem(Sto_key);
					mui.toast("数据保存完毕")
				});
			},
			open(s) {
				app.open(_subpageurls[0], s);
			}
		},
		//计算属性
		computed: {
			uname() {
				return this.formdata.uname
			}
		},
		//监听器
		watch: {
			uname(newValue, oldValue) {
				this.formdata.py = _PY.make(newValue);
			}
		},
		//数据,事件已经初始化,el未绑定,dom未渲染
		beforeMount: function() {},
		beforeCreate() {},
		created() {
			//el已绑定 dom已渲染							
			//console.log('create',this.$loading)
			this.timer = setInterval(this.onTask, 5000);
			/* 	Dao.MD.getObjByID(1,function(rc) {
					console.log("mounted",rc)
					vm.formdata = rc
				}); */
			/* 		Dao.MD.getList(function(rs) {
						vm.list = rs
					}); */

		},
		mounted() {},
		beforeDestroy() {
			if (this.timer) clearInterval(this.timer);
		},
	};
	// 回调
	function afterWindowAck(e) {
		//console.log("afterWindowAck", e.detail.msg);
		if (e.detail.code == 1) {
			vm.iniDict(e.detail.msg);
		}
	}
	// 
	function afterPlusReady() {

		//vm.$loading();	
		var future = _Syn.Future(3, function() {
			vm = new Vue(vuedata);
			vm.$mount('#el'); // 全部完成后绑定		
		});

		//先载入数据
		confDao.getDict('gclass', function(rc) { //读取数据,初始化组件
			console.log('gclass',rc)
			vuedata.data.dict.gclass = rc;
			future.light(0);
		});
		//console.log('_request',_request)
		//如果传过来id,那么从数据库查询			
		if (_request.id && _request.id > 0) {
			userDao.MD.getObjByID(_request.id, function(rs, sql) {
				// console.log()
				vuedata.data.formdata = rs;
				future.light(2);
			});
			application = 'update';
		} else {
			var data = _STO.getItem(Sto_key);
			if (!data)
				data = userDao.MD.createMData();
			vuedata.data.formdata = data;
			future.light(2);
			application = 'add';
		}

	}
</script>
<script src="../../hyl/pageStart.js"></script>
